/* This file is part of MyRename
 * Copyright (C) 2005-2009 Kai-Chieh Ku (kjackie@gmail.com)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#pragma once

#include "ResizableLib/ResizableDialog.h"
#include "dirtreectrl.h"
#include "prelistctrl.h"
#include "postlistctrl.h"
#include "splittercontrol.h"

#define FILEWND (((CMyRenameDlg *)theApp.m_pMainWnd)->m_pFilewnd)

//Timer IDs
enum {
	FT_LOCK = 1,
	FT_UPDATE,
	FT_UPDATER
};

typedef struct {
	bool bUpLeft;
	const CFileName *mask;
} UpThreadParam;

// CFileWnd dialog

class CFileWnd : public CResizableDialog
{
	DECLARE_DYNAMIC(CFileWnd)

public:
	CFileWnd(CWnd* pParent = NULL);   // standard constructor
	virtual ~CFileWnd();

// Dialog Data
	enum { IDD = IDD_FILEWND };

	virtual BOOL OnInitDialog();
protected:
	CSplitterControl m_leftSplitter;
	CSplitterControl m_rightSplitter;
	int GetSplitterPos(bool left = true, bool percent = true);
public:
	CPreListCtrl m_PreList;
	CPostListCtrl m_PostList;
	CDirTreeCtrl  m_DirTree;
	void UpdateList(bool update_left = false, const CFileName *mask = NULL);
	void LockUpdate(UINT uTime = 0);
	void UnlockUpdate();
	void Localize();

	bool m_bLockUpdate;
private:
	void DoResize(int delta, UINT nID);
	void UpdateSplitter();
	void UpdateSplitterRange();
	void UpdateAnchors(bool bRemoveFirst = false);
	UINT_PTR m_uTimer;
protected:
	virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam);
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

	DECLARE_MESSAGE_MAP()
public:
	afx_msg void OnTimer(UINT nIDEvent);
};
